//首页a标签的实现
var studya='<p align="center">' +
    '<img src="image/study.png" width="35%"/>' +
    '<p style="margin-top: 25px;" align="center">学习</p>'+
    ' </p>';
var studyt='<p align="center">' +
    '<img src="image/test.png" width="50%"/>' +
    '<p style="margin-top: 28px;" align="center">测试</p>' +
    '</p>';
var studyc='<p align="center">' +
    '<img src="image/collect.png" width="40%"/>' +
    '<p style="margin-top: 22px;" align="center">我的</p>' +
    '</p>';
function aaa(){
    var study_a=  document.getElementById('study_a');
    var test_a=  document.getElementById('test_a');
    var collect_a=  document.getElementById('collect_a');
    study_a.onclick=function(){
        var study2='<p>&nbsp;请选择:</p>' +
            '<p align="center">' +
            '<a href="study_base.html">基础知识</a><br/>' +
            '<a href="study_attainment.html">信息素养</a>' +
            '</p>';   '</p>';
        test_a.innerHTML=studyt;
        collect_a.innerHTML=studyc;
        study_a.innerHTML="";
        study_a.innerHTML=study2;
        setTimeout("study_aa();",3000);
    }
    test_a.onclick=function(){
        var study3='<p>&nbsp;请选择:</p>' +
            '<p align="center">' +
            '<a href="test_base.html">基础知识</a><br/>' +
            '<a href="test_attainment.html">信息素养</a>' +
            '</p>';
        study_a.innerHTML=studya;
        collect_a.innerHTML=studyc;
        test_a.innerHTML="";
        test_a.innerHTML=study3;
        setTimeout("test_aa();",3000);
    }
    collect_a.onclick=function(){
        var study4='<p>&nbsp;请选择:</p>' +
            '<p align="center">' +
            '<a href="collect.html">收藏</a><br/>' +
            '<a href="wrong.html">错题集</a>' +
            '</p>';
        study_a.innerHTML=studya;
        test_a.innerHTML=studyt;
        collect_a.innerHTML="";
        collect_a.innerHTML=study4;
        setTimeout("collect_aa();",3000);
    }
}
function study_aa(){
    document.getElementById('study_a').innerHTML=studya;
}
function test_aa(){
    document.getElementById('test_a').innerHTML=studyt;
}
function collect_aa(){
    document.getElementById('collect_a').innerHTML=studyc;
}

//首页侧边栏实现
window.onload=function(){
    var odiv=document.getElementById('sidebar');
    odiv.onmouseover=function ()
    {
        startmove(0,10);//第一个参数为div   left属性的目标值   第二个为 每次移动多少像素
        document.getElementById('popWindow').style.display = 'block';       //出现蒙版
        document.getElementById('container').style.pointerEvents="none";        //禁用container的a标签
    }
    odiv.onmouseout=function ()
    {
        startmove(-200,-10);        //回收侧边栏
        document.getElementById('popWindow').style.display = 'none';        //蒙版消失
        setTimeout("document.getElementById('container').style.pointerEvents='auto';",10);      //解禁container的a标签
    }
}

var timer=null;
function startmove(target,speed)        //侧边栏的具体移动
{

    var odiv=document.getElementById('sidebar');
    clearInterval(timer);
    timer=setInterval(function (){

        if(odiv.offsetLeft==target)
        {
            clearInterval(timer);
        }
        else
        {
            odiv.style.left=odiv.offsetLeft+speed+'px';
        }

    },30)

}
//侧边栏滑动
// function load (){
//     var startX, endX;
//     var elem = document.getElementById("container");
//     var elem_child = elem.childNodes;
//     var j = 0;
//     for(var i = 0; i < elem_child.length; i++){
//         elem_child[i].addEventListener('touchstart', tstart, false);
//         elem_child[i].addEventListener('touchend', tend, false);
//     }
//     function tstart(event) {
//         var event = event || window.event;
//         event.preventDefault();
//         startX = event.touches[0].clientX;
//     }
//     function tend(event) {
//         var event = event || window.event;
//         endX = event.changedTouches[0].clientX;
//         event.preventDefault();
//         if((startX - endX) > 100) {       //右往左移动
//             startmove(-200,-10);        //回收侧边栏
//             document.getElementById('popWindow').style.display = 'none';        //蒙版消失
//             setTimeout("document.getElementById('container').style.pointerEvents='auto';",10);
//
//         }
//         else if((startX - endX) < -100){   //左往右移动
//
//             startmove(0,10);//第一个参数为div   left属性的目标值   第二个为 每次移动多少像素
//             document.getElementById('popWindow').style.display = 'block';       //出现蒙版
//             document.getElementById('container').style.pointerEvents="none";        //禁用container的a标签
//         }
//     }
// }
// window.addEventListener('load',load, false);


$(document).ready(function(){       //解析的实现
	$("#submit_subject").ready(function(){
		$("#detail").hide();
	});
	$("#submit_subject").click(function(){
		$("#detail").toggle(1000);
	});
});


function chred(ele){        //选择题选择的实现
    var f = ele.checked;
    ele.parentNode.style.background="darkorange";
    var radios = document.getElementsByName(ele.name);
    for(var i = 0; i<radios.length; i++){
        if(radios[i].checked == false){
            radios[i].parentNode.style.background="#FFFFFF";
        }
    }
}